tools: gdbsx: Check return of write()
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 3 Nov 2010 11:58:25 +0000 (11:58 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 3 Nov 2010 11:58:25 +0000 (11:58 +0000)
Not checking leads to warn_unused_result checks triggering in some
libraries and compilers.  Combined with -Werror this breaks the build.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/debugger/gdbsx/gx/gx_comm.c

index 156a9f5f5532574bc654c4239754ec5984fdd610..ed4a7bef0eb34aa3f2644b1d6232ba09a80277c7 100644 (file)
@@ -227,13 +227,19 @@ gx_getpkt (char *buf)
         
         gxprt("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
               (c1 << 4) + c2, csum, buf);
-        write(remote_fd, "-", 1);
+        if (write(remote_fd, "-", 1) != 1) {
+            perror("write");
+            return -1;
+        }
     }
     if (gx_remote_dbg) {
         gxprt("getpkt (\"%s\");  [sending ack] \n", buf);
     }
         
-    write(remote_fd, "+", 1);
+    if (write(remote_fd, "+", 1) != 1) {
+        perror("write");
+        return -1;
+    }
         
     if (gx_remote_dbg) {
         gxprt("[sent ack]\n");